package com.turing.post.tuxedo.util;

import java.io.Serializable;

import org.jdom2.Element;

import com.turing.post.util.PCPSApplicationException;
import com.turing.post.util.PCPSUtil;

/**
 * 卡对象信息
 * 
 * @author yxb
 * 
 */
@SuppressWarnings("serial")
public class CardObj implements Serializable {
	/**
	 * 卡号或卡顺序号
	 */
	public String cardNo = "";

	/**
	 * 二磁道信息
	 */
	public String track2 = "";

	/**
	 * 三磁道信息
	 */
	public String track3 = "";

	/**
	 * 解析卡对象
	 * 
	 * @param node
	 *            节点
	 * @param isOptional
	 *            是否可选
	 * @throws Exception
	 */
	public void parseCardObj(Element node, boolean isOptional)
			throws PCPSApplicationException {
		cardNo = TransXmlHelper.getOptionalString(node,
				TransXmlHelper.XML_NODE_CardNo);
		track2 = TransXmlHelper.getOptionalString(node,
				TransXmlHelper.XML_NODE_Track2);
		track3 = TransXmlHelper.getOptionalString(node,
				TransXmlHelper.XML_NODE_Track3);
		if (!isOptional && PCPSUtil.isEmpty(cardNo) && PCPSUtil.isEmpty(track2)
				&& PCPSUtil.isEmpty(track3))
			ParaseException
					.TransParamException("cardNo & track2 & track3 all empty!");
	}
}
